﻿namespace Algoritmia.SemiRings
{
    public class BooleanSemiRing : IIdempotentSemiRing<bool>
    {
        private static BooleanSemiRing _instance;

        private BooleanSemiRing()
        {
        }

        public static BooleanSemiRing GetInstance()
        {
            _instance = _instance ?? new BooleanSemiRing();
            return _instance;
        }

        #region Implementation of ISemiRing<bool>

        public bool Zero
        {
            get { return false; }
        }

        public bool One
        {
            get { return true; }
        }

        public bool Plus(bool left, bool right)
        {
            return left || right;
        }

        public bool Times(bool left, bool right)
        {
            return left && right;
        }

        #endregion
    }
}
